]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
cleanup: Replace non-standard ByteArray module
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 12 Aug 2021 14:38:57 +0000 (16:38 +0200)
committerMarge Bot <marge-bot@gnome.org>
Wed, 1 Sep 2021 14:49:30 +0000 (14:49 +0000)
gjs landed support for TextDecoder/TextEncoder. Use those instead
of gjs' own ByteArray module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1946>

.gitlab-ci.yml
js/misc/fileUtils.js
js/ui/components/networkAgent.js
js/ui/environment.js
js/ui/extensionDownloader.js
js/ui/extensionSystem.js
js/ui/keyboard.js
js/ui/padOsd.js
js/ui/sessionMode.js
meson.build
subprojects/extensions-app/js/main.js

index 5f97c3312a38c590a1a01c230a78313f0a22583e..97aff402712dbb18eec8398210f9320858d0361d 100644 (file)
@@ -31,7 +31,7 @@ variables:
     LINT_LOG: "eslint-report.xml"
     LINT_MR_LOG: "eslint-mr-report.xml"
 
-image: registry.gitlab.gnome.org/gnome/mutter/fedora/34:x86_64-2021-08-01.0
+image: registry.gitlab.gnome.org/gnome/mutter/fedora/34:x86_64-2021-08-25.0
 
 workflow:
     rules:
index 2f1798b84b0244839d82bfb5102e3f3d490dd234..88f043a79a3ae43dc88bea47ff6ec28d6d868da7 100644 (file)
@@ -86,7 +86,7 @@ function loadInterfaceXML(iface) {
 
     try {
         let [ok_, bytes] = f.load_contents(null);
-        return imports.byteArray.toString(bytes);
+        return new TextDecoder().decode(bytes);
     } catch (e) {
         log(`Failed to load D-Bus interface ${iface}`);
     }
index 9a1885a038f1c83abe7db3a8e28a794e36e02337..92e499302aca0fc1db447769417f50cac3cfa00e 100644 (file)
@@ -2,7 +2,6 @@
 /* exported Component */
 
 const { Clutter, Gio, GLib, GObject, NM, Pango, Shell, St } = imports.gi;
-const ByteArray = imports.byteArray;
 const Signals = imports.signals;
 
 const Dialog = imports.ui.dialog;
@@ -498,7 +497,8 @@ var VPNRequestHandler = class {
             return;
         }
 
-        this._vpnChildProcessLineOldStyle(ByteArray.toString(line));
+        const decoder = new TextDecoder();
+        this._vpnChildProcessLineOldStyle(decoder.decode(line));
 
         // try to read more!
         this._readStdoutOldStyle();
@@ -527,7 +527,7 @@ var VPNRequestHandler = class {
         let contentOverride;
 
         try {
-            data = ByteArray.toGBytes(this._dataStdout.peek_buffer());
+            data = new GLib.Bytes(this._dataStdout.peek_buffer());
             keyfile.load_from_bytes(data, GLib.KeyFileFlags.NONE);
 
             if (keyfile.get_integer(VPN_UI_GROUP, 'Version') != 2)
index 89ff701c70532a632f9e3af7e1b484d3ff70b12d..ccd7dcdaa6e3f0dc86204069e339777e81f64030 100644 (file)
@@ -86,8 +86,6 @@ function _patchLayoutClass(layoutClass, styleProps) {
  * @returns {void}
  */
 function _injectSoup3Compat(Soup) {
-    const ByteArray = imports.byteArray;
-
     Soup.StatusCode = Soup.KnownStatusCode;
 
     Soup.Message.new_from_encoded_form =
@@ -101,7 +99,7 @@ function _injectSoup3Compat(Soup) {
             this.set_request(
                 contentType,
                 Soup.MemoryUse.COPY,
-                ByteArray.toString(bytes.get_data()));
+                new TextDecoder().decode(bytes.get_data()));
         };
 
     Soup.Session.prototype.send_and_read_async =
index d1c899fa00ea0d19e8ac61087ed4a9f97e22fdec..8bf4646a6aa3080df709d3436a1da0e534776566 100644 (file)
@@ -3,8 +3,6 @@
 
 const { Clutter, Gio, GLib, GObject, Soup } = imports.gi;
 
-const ByteArray = imports.byteArray;
-
 const Config = imports.misc.config;
 const Dialog = imports.ui.dialog;
 const ExtensionUtils = imports.misc.extensionUtils;
@@ -49,7 +47,8 @@ async function installExtension(uuid, invocation) {
             GLib.PRIORITY_DEFAULT,
             null);
         checkResponse(message);
-        info = JSON.parse(ByteArray.toString(bytes.get_data()));
+        const decoder = new TextDecoder();
+        info = JSON.parse(decoder.decode(bytes.get_data()));
     } catch (e) {
         Main.extensionManager.logExtensionError(uuid, e);
         invocation.return_dbus_error(
@@ -181,8 +180,7 @@ async function checkForUpdates() {
         shell_version: Config.PACKAGE_VERSION,
         disable_version_validation: versionCheck.toString(),
     };
-    const requestBody = new GLib.Bytes(
-        ByteArray.fromString(JSON.stringify(metadatas)));
+    const requestBody = new GLib.Bytes(JSON.stringify(metadatas));
 
     const message = Soup.Message.new('POST',
         '%s?%s'.format(REPOSITORY_URL_UPDATE, Soup.form_encode_hash(params)));
@@ -195,7 +193,7 @@ async function checkForUpdates() {
             GLib.PRIORITY_DEFAULT,
             null);
         checkResponse(message);
-        json = ByteArray.toString(bytes.get_data());
+        json = new TextDecoder().decode(bytes.get_data());
     } catch (e) {
         log('Update check failed: %s'.format(e.message));
         return;
index 6b624fca09a1456ecd5cdc5daa6e237300e8dcf4..cc61cab403f2dbd3b15378d56cb79706852decd1 100644 (file)
@@ -2,7 +2,6 @@
 /* exported init connect disconnect */
 
 const { GLib, Gio, GObject, Shell, St } = imports.gi;
-const ByteArray = imports.byteArray;
 const Signals = imports.signals;
 
 const ExtensionDownloader = imports.ui.extensionDownloader;
@@ -285,7 +284,7 @@ var ExtensionManager = class {
         let metadataContents, success_;
         try {
             [success_, metadataContents] = metadataFile.load_contents(null);
-            metadataContents = ByteArray.toString(metadataContents);
+            metadataContents = new TextDecoder().decode(metadataContents);
         } catch (e) {
             throw new Error('Failed to load metadata.json: %s'.format(e.toString()));
         }
index d0dde5b23aa5f22672dbfc4fcdeed646d27ba763..0597e82e4a9f6ed5b4dd1e2c50e0e871c787ebd4 100644 (file)
@@ -2,7 +2,6 @@
 /* exported KeyboardManager */
 
 const { Clutter, Gio, GLib, GObject, Graphene, Meta, Shell, St } = imports.gi;
-const ByteArray = imports.byteArray;
 const Signals = imports.signals;
 
 const EdgeDragAction = imports.ui.edgeDragAction;
@@ -536,9 +535,9 @@ var KeyboardModel = class {
     _loadModel(groupName) {
         let file = Gio.File.new_for_uri('resource:///org/gnome/shell/osk-layouts/%s.json'.format(groupName));
         let [success_, contents] = file.load_contents(null);
-        contents = ByteArray.toString(contents);
 
-        return JSON.parse(contents);
+        const decoder = new TextDecoder();
+        return JSON.parse(decoder.decode(contents));
     }
 
     getLevels() {
@@ -1039,9 +1038,7 @@ var EmojiSelection = GObject.registerClass({
         let file = Gio.File.new_for_uri('resource:///org/gnome/shell/osk-layouts/emoji.json');
         let [success_, contents] = file.load_contents(null);
 
-        if (contents instanceof Uint8Array)
-            contents = imports.byteArray.toString(contents);
-        let emoji = JSON.parse(contents);
+        let emoji = JSON.parse(new TextDecoder().decode(contents));
 
         let variants = [];
         let currentKey = 0;
index ed207415add056155ca6a67871436f68497fc6a7..9804f9e305748bdda4a87420c1f1a5527d5a0451 100644 (file)
@@ -3,7 +3,6 @@
 
 const { Atk, Clutter, GDesktopEnums, Gio,
         GLib, GObject, Gtk, Meta, Pango, Rsvg, St } = imports.gi;
-const ByteArray = imports.byteArray;
 const Signals = imports.signals;
 
 const Main = imports.ui.main;
@@ -298,10 +297,9 @@ var PadDiagram = GObject.registerClass({
     _init(params) {
         let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/pad-osd.css');
         let [success_, css] = file.load_contents(null);
-        css = ByteArray.toString(css);
         this._curEdited = null;
         this._prevEdited = null;
-        this._css = css;
+        this._css = new TextDecoder().decode(css);
         this._labels = [];
         this._activeButtons = [];
         super._init(params);
index 4d4fb2444c35174ba6ef4bedbebfa40d08d9becc..afcd67cfd22617c46880e4b4b996e384d5e62445 100644 (file)
@@ -1,7 +1,6 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported SessionMode, listModes */
 
-const ByteArray = imports.byteArray;
 const GLib = imports.gi.GLib;
 const Signals = imports.signals;
 
@@ -110,8 +109,8 @@ function _loadMode(file, info) {
     let fileContent, success_, newMode;
     try {
         [success_, fileContent] = file.load_contents(null);
-        fileContent = ByteArray.toString(fileContent);
-        newMode = JSON.parse(fileContent);
+        const decoder = new TextDecoder();
+        newMode = JSON.parse(decoder.decode(fileContent));
     } catch (e) {
         return;
     }
index 58475005130d5f533c6589f6b13d06afab826c89..41f5b02a34cc1754968f79b23a1d189775c28fe5 100644 (file)
@@ -24,7 +24,7 @@ eds_req = '>= 3.33.1'
 gcr_req = '>= 3.7.5'
 gio_req = '>= 2.56.0'
 gi_req = '>= 1.49.1'
-gjs_req = '>= 1.68.1'
+gjs_req = '>= 1.69.2'
 gtk_req = '>= 3.15.0'
 mutter_req = '>= 41.beta'
 polkit_req = '>= 0.100'
index d4b6ec79fde377748f4ec07e310dda7d906a1546..48d382f3f67e8d7ecffea320af425254db7a9518 100644 (file)
@@ -24,7 +24,7 @@ function loadInterfaceXML(iface) {
 
     try {
         let [ok_, bytes] = f.load_contents(null);
-        return imports.byteArray.toString(bytes);
+        return new TextDecoder().decode(bytes);
     } catch (e) {
         log('Failed to load D-Bus interface %s'.format(iface));
     }